#pragma once
#include "Vector4.h"
#include "Matrix44.h"

template <class T>
class Quaternion
{
public:
	Quaternion(void); // construct a unit quaternion
	Quaternion(T r,T x,T y,T z);
	Quaternion(const Vector4<T>& vec);
	Quaternion(const Vector3<T>& axis, T angle);
	~Quaternion(void)
	{}

	Quaternion<T> operator+(const Quaternion<T>& rhs) const;
	Quaternion<T> operator-(const Quaternion<T>& rhs) const;
	Quaternion<T> operator*(const Quaternion<T>& rhs) const;
	Quaternion<T> operator*(T scalar) const;
	Quaternion<T>& operator*=(T scalar);
	Quaternion<T> operator/(T scalar) const;
	Quaternion<T> operator-() const;

	// rotate a vector
	Vector3<T> operator*(const Vector3<T>& rhs) const;
	Quaternion<T> conjugate() const;
	Quaternion<T>& normalize();
	T dot(const Quaternion<T>& rhs) const;
	static Quaternion<T> slerp(const Quaternion<T>& q1, const Quaternion<T>& q2, T t);

	void getMatrix(Matrix44<T>& mat4) const;

	T r,x,y,z;
};

#include "Quaternion.inl"

typedef Quaternion<float> quatf;